/**
 * Created by YHB on 2015/6/25.
 */

define(['zepto'], function ($) {
    function Tips(){
        this.oTipsBox = $('#tips');
        this.oTipMsg = this.oTipsBox.find('#tips-msg');
        this.oTipImg = this.oTipsBox.find('img');
    }
    /**
     * @method showTip 显示提示信息
     * @param msg
     * @param showImg
     */
    Tips.prototype.showTip = function (msg, showImg) {
        this.oTipMsg.html(msg);
        showImg ? this.oTipImg.show() : this.oTipImg.hide();
        this.oTipsBox.show();
        this.oTipsBox.css({
            marginLeft: -(document.getElementById("tips-msg").clientWidth / 2 + 10) + "px",
            marginTop: -(document.getElementById("tips-msg").clientHeight / 2 + 10) + "px"
        });
    };

    /**
     * @method hideTip 隐藏提示
     * @param delay 延时时间
     */
    Tips.prototype.hideTip = function (delay) {
        var self = this;
        delay = delay ? delay: 500;
        setTimeout(function() {
            self.oTipsBox.hide();
        }, delay);
    }
    return new Tips();
});


